package cn.tom.tool;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Demo {
    private String name;
    private Integer age;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Demo{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public static void main(String[] args) {
        Demo user1 = new Demo();
        user1.setName("李世民");
        user1.setAge(44);

        Demo user2 = new Demo();
        user2.setName("朱章基");
        user2.setAge(55);

        List<Demo> userList =
                Stream.of(user1, user2).collect(Collectors.toList());

        userList.stream().forEach(str -> {
            System.out.println("姓名:" + str.getName() + "\n" + "年龄:" + str.getAge());
        });
    }
}
